"""
提交链接：https://leetcode.cn/problems/house-robber/
lc198.打家劫舍
mudium,吴奇峰 2024.9.18
动态规划
"""


class Solution(object):
    def rob(self, nums) -> int:
        """
        :type nums: List[int]
        :rtype: int
        """
        n = len(self.nums)
        dp = [0]*(n+1)
        dp[1] = nums[0]
        for i in range(2,n+1):
            dp[i] = max(dp[i-1],dp[i-2]+nums[i-1])
        return dp[-1]